package xdu.lz.stage2_design_pattern.chapter18_active_object_pattern;

/**
 * 真正实现ActiveObject的方法，奴仆
 */
public class Servant implements ActiveObject {

    @Override
    public Result makeString(int count, char fillChar) {
        char [] charArr = new char[count];
        for (int i = 0; i < count; i++) {
            charArr[i] = fillChar;
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        //返回真正做事的RealResult
        return new RealResult(new String(charArr));
    }

    @Override
    public void displayString(String text) {
        System.out.println("display " + text);
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
